package com.igroupes.ovineherd.model.Style;


import com.igroupes.ovineherd.exception.ModelException;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@EqualsAndHashCode(callSuper = true)
@Slf4j
@Data
@ToString(callSuper = true)
public class BasicStyle extends ShowStyle{
    protected String label; //标签前段实现用
    protected String type; //表单类型
    protected Boolean disabled; //只读，true 是 false 不是
    protected String desc = ""; //只是前段显示用

    public BasicStyle() {
        super();
    }

    protected BasicStyle(String label, Object value) {
        super(value);
        this.label =label;
        this.disabled = false;
    }

    @Override
    public Boolean verify(Object o) {
        super.verify(o);
        BasicStyle showStyle = (BasicStyle) o;
        if(!(showStyle.getType() instanceof String)){
            log.error("form传值类型错误, {}", o);
            throw new ModelException("form传值类型错误");
        }
        if(!(showStyle.getDisabled() instanceof Boolean)){
            log.error("readonly传值类型错误, {}", o);
            throw new ModelException("readonly传值类型错误");
        }

        return true;
    }
}
